package com.lyu.xiaolvshu.user.biz.rpc;

import com.lyu.framework.common.response.Response;
import com.lyu.xiaolvshu.oss.api.FileFeignApi;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.Objects;

@Component
@Slf4j
public class OssRpcService {

    @Resource
    private FileFeignApi fileFeignApi;

    public String uploadFile(MultipartFile file) {
        Response<?> response = fileFeignApi.uploadFile(file);
        if (Objects.isNull(response) || !response.isSuccess()) {
            return null;
        }
        return (String) response.getData();
    }
}
